package com.xxyf.scheduling;

import com.xxyf.entity.Like;
import com.xxyf.service.LikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author 小小怡飞
 * @Date 2023/3/2 23:36
 * @Version JDK 8
 */

@Component
public class Scheduling {
    @Autowired
    private LikeService likeService;
    @Scheduled(cron = "0 0 0/1 * * ? ")
    @Transactional
    public void execute(){
        //开启定时任务两小时一次用来同步数据库
        likeService.updata();
    }

}
